package com.firefly.dao.assembler.ums;

import com.firefly.dao.dao.ums.po.DepartmentPo;
import com.firefly.dao.dto.ums.DepartmentDto;
import com.firefly.dao.dto.ums.DepartmentStatusDto;
import com.firefly.dao.vo.ums.DepartmentTreeVo;
import com.firefly.dao.vo.ums.DepartmentVo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 部门数据类型转换
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/11/30
 **/
@Component
public class DepartmentAssembler {
    public List<DepartmentTreeVo> getTreeList(List<DepartmentPo> list) {
        List<DepartmentTreeVo> result = new ArrayList<>();
        list.forEach(item -> {
            DepartmentTreeVo tmp = new DepartmentTreeVo();
            tmp.setId(item.getId());
            tmp.setParentId(item.getParentId());
            tmp.setName(item.getName());
            tmp.setStatus(item.getStatus());
            result.add(tmp);
        });
        return result;
    }

    public List<DepartmentVo> getListVo(List<DepartmentPo> list) {
        List<DepartmentVo> result = new ArrayList<>();
        list.forEach(item -> {
            DepartmentVo tmp = new DepartmentVo();
            tmp.setId(item.getId());
            tmp.setParentId(item.getParentId());
            tmp.setName(item.getName());
            tmp.setStatus(item.getStatus());
            result.add(tmp);
        });
        return result;
    }

    public DepartmentVo getVo(DepartmentPo entity) {
        DepartmentVo detail = new DepartmentVo();
        detail.setId(entity.getId());
        detail.setParentId(entity.getParentId());
        detail.setName(entity.getName());
        detail.setStatus(entity.getStatus());
        return detail;
    }

    public DepartmentPo getPo(DepartmentDto detail) {
        DepartmentPo entity = new DepartmentPo();
        entity.setId(detail.getId());
        entity.setParentId(detail.getParentId());
        entity.setName(detail.getName());
        entity.setStatus(detail.getStatus());
        return entity;
    }

    public DepartmentPo getPo(DepartmentStatusDto detail) {
        DepartmentPo entity = new DepartmentPo();
        entity.setId(detail.getId());
        entity.setStatus(detail.getStatus());
        return entity;
    }
}
